<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateBookTypeTable extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $item = $this->table('book_type', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '知识本项目类型']);

        $item->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('name', 'string', ['default' => '', 'limit' => 255, 'comment' => '类型名称'])
            ->addColumn('icon', 'string', ['default' => '', 'limit' => 255, 'comment' => '图标'])
            ->addColumn('number', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '序号'])
            ->addColumn("type", 'integer', ['limit' => 5, 'default' => 1, 'comment' => '知识库类型:1.平台,2.租户,3.文件'])
            ->addColumn("description", 'text', ['default' => null, 'comment' => '项目描述'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户ID'])
            ->addColumn("created_by", 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn("created", 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('updated', 'integer',  ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '更新时间'])
            ->addColumn("attribute", 'integer', ['limit' => 5, 'default' => 1, 'comment' => '属性:1.公开,2.私有'])
            ->save();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('book_type');
    }
}
